#ifndef COMMON_H
#define COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <libavformat/avformat.h>
#include <libavutil/time.h>
#include <libavutil/mathematics.h>
#include "mk_mediakit.h"
#include "mk_track.h"

#define MAX_CAMERAS 2

// 全局变量声明
extern int server_initialized;
extern mk_media g_media[MAX_CAMERAS];

// 摄像头流配置
typedef struct {
    const char* input_stream;
    int cam_id;
} CameraStream;

// 流状态结构体
typedef struct {
    int video_inited;
    int audio_inited;
    int init_completed;
    pthread_mutex_t mutex;
} StreamState;

extern StreamState g_stream_states[MAX_CAMERAS];

// 函数声明
void start_zlmediakit_server_once();
mk_media create_stream(const char* stream_id);
void add_adts_header(uint8_t *data, int data_len, int sample_rate, int channels);

#endif // COMMON_H
